home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2002 #4 / K-CD-4-2002.ISO / Empire Earth / EEDemo.exe / Disk1 / data.ssa / unit ai scripts_generic attack.tai < prev    next >
Encoding:
Text File  |  2001-09-29  |  5.3 KB  |  164 lines

  1. //
  2. //    Generic Attack AI file
  3. //
  4. //    Behaviors:
  5. //
  6. //        When idle, periodically look for an enemy unit to attack.
  7. //        Attempt to keep target in weapon range by moving and/or facing when target moves.
  8. //        Return to idle state when target dies or moves out of LOS.
  9. //
  10. //    Notes:
  11. //
  12. //        When using this file with the Generic Movement AI file, you should include this file first.
  13. //            Failure to do so will result in units that don't stop when in weapon range or when
  14. //            their target dies.  Your unit will look stupid.
  15. //
  16. //    Common modifications:
  17. //
  18. //        To abort the attack early with a new trigger, insert a new AttackEnemyUnit and
  19. //            FaceEnemyUnit transition specification before including this file.
  20. //        To prevent pursuit of fleeing enemies, place new FaceEnemyUnit:UnitNotInWeaponRange
  21. //            and AttackEnemyUnit:UnitNotInWeaponRange transition specifications after
  22. //            including this file.
  23. //        To prevent following a faster target, place a new ReacquireGoal:GoalIsUnit transition
  24. //            specification after including this file.
  25. //
  26. //    Known Problems:
  27. //
  28. //    Usage:
  29. //
  30. //        To tell a unit to attack another unit, give it an attack goal (EEUGAttackUnit or EEUGAttackGround)
  31. //            and set it's action to keeuaAttackEnemyUnit.
  32. //
  33.  
  34. // any good targets around?
  35. Idle
  36. {    
  37.     CanISeeEnemy true(CheckRange)
  38.     // we no longer poll to see if we're under attack - notification comes from EEUnit::TakeDamage()
  39. }
  40.  
  41. // is the target in weapon range already?
  42. CheckRange
  43. {
  44.     anyof(EnemyUnitDestroyed,CeaseFire,UnitNotOnMap,EnemyWithinMinimumRange) true(ShouldIReturnToInitialContactLocation)
  45.     allof(EnemyUnitNoLongerVisible,GoalIsNotPlayerInitiated) true(ShouldIReturnToInitialContactLocation)
  46.     UnitInWeaponRange true(FaceEnemyUnit) 
  47.     anyof(CanIMoveFreely,GoalIsPlayerInitiated) true(ShouldIFollowEnemyUnit) false(ShouldIReturnToInitialContactLocation)
  48. }
  49.  
  50. // stop moving toward the target if we achieve weapon range
  51. GetNextMoveWaypoint
  52. {
  53.     anyof(EnemyUnitDestroyed,CeaseFire) true(ShouldIReturnToInitialContactLocation)
  54.     allof(GoalIsAttackLocation,LocationInWeaponRange) true(FaceLocation)
  55.     allof(AttackerIsRangedUnit,UnitInWeaponRange) true(FaceEnemyUnit)
  56.     EnemyUnitMoved true(CheckRange)
  57. }
  58.  
  59. // should I follow the enemy unit? 
  60. ShouldIFollowEnemyUnit
  61. {
  62.     allof(OneWaypointRemaining,GoalIsUnit,EnemyUnitHasNotMovedOneTile) true(Advance)
  63.     anyof(CanIPursuePastInitialContactLOS,EnemyInsideInitialContactLOS,GoalIsPlayerInitiated) true(PrepareToMove) false(ShouldIReturnToInitialContactLocation)
  64. }
  65.  
  66. // face our target until it is destroyed or moves
  67. FaceEnemyUnit
  68. {
  69.     ShouldIRun true(RunFromAttacker)
  70.     anyof(EnemyUnitDestroyed,CeaseFire,UnitNotOnMap,EnemyWithinMinimumRange) true(ShouldIReturnToInitialContactLocation)
  71.     allof(EnemyUnitNoLongerVisible,GoalIsNotPlayerInitiated) true(ShouldIReturnToInitialContactLocation)
  72.     UnitInWeaponRange false(CheckRange)
  73.     allof(TargetIsSpecialEnemy,Reloaded,EnemyUnitInsideFiringArch) true(ChangeTargetForSpecialEnemy)
  74.     allof(Reloaded,EnemyUnitInsideFiringArch) true(AttackEnemyUnit)
  75.     FacingEnemyUnit true(WaitForReload)
  76. }
  77.  
  78. ChangeTargetForSpecialEnemy
  79. {
  80.     AlwaysTrue true(ReacquireGoal)
  81. }
  82.  
  83. // attack the target until it is destroyed or moves
  84. AttackEnemyUnit
  85. {
  86.     ShouldIRun true(RunFromAttacker)
  87.     ShouldIRetaliate true(RetaliateAgainstAttacker)
  88.     EnemyUnitInsideFiringArch false(FaceEnemyUnit)
  89.     AlwaysTrue true(WaitForReload)
  90. }
  91.  
  92.  
  93. // face our target until it is destroyed or moves
  94. FaceLocation
  95. {
  96.     ShouldIRun true(RunFromAttacker)
  97.     ShouldIRetaliate true(RetaliateAgainstAttacker)
  98.     CeaseFire true(Idle)
  99.     LocationInWeaponRange false(PrepareToMove)
  100.     allof(Reloaded,LocationInsideFiringArch) true(AttackLocation)
  101.     anyof(LocationInsideFiringArch) true(WaitForReload)
  102. }
  103.  
  104. // attack the target location forever
  105. AttackLocation
  106. {
  107.     ShouldIRun true(RunFromAttacker)
  108.     ShouldIRetaliate true(RetaliateAgainstAttacker)
  109.     LocationInsideFiringArch false(FaceLocation)
  110.     AlwaysTrue true(WaitForReload)
  111. }
  112.  
  113.  
  114. // wait for reload - this guarentees that we get at least 1 attack off 
  115. WaitForReload
  116. {
  117.     ShouldIRun true(RunFromAttacker)
  118.     ShouldIRetaliate true(RetaliateAgainstAttacker)
  119.     allof(GoalIsAttackLocation,Reloaded) true(FaceLocation)
  120.     Reloaded true(FaceEnemyUnit)
  121.     anyof(EnemyUnitDestroyed,CeaseFire,UnitNotOnMap,EnemyWithinMinimumRange) true(ShouldIReturnToInitialContactLocation)
  122.     allof(EnemyUnitNoLongerVisible,GoalIsNotPlayerInitiated) true(ShouldIReturnToInitialContactLocation)
  123. }
  124.  
  125. // attack the target until it is destroyed or moves
  126. InitialAttackState
  127. {
  128.     //Reloaded false(WaitForReload)
  129.     GoalIsUnit true(FaceEnemyUnit)
  130.     GoalIsAttackLocation true(FaceLocation)
  131. }
  132.  
  133. // ReAcquire Goal
  134. // BlockedByWall needs to come first
  135. // Followed by the tests for the various possible goals
  136.  
  137. ReacquireGoal
  138. {
  139.     BlockedByWall true(ShouldIReturnToInitialContactLocation)
  140.     GoalIsUnit true(ReacquireEnemyUnit)
  141.     GoalIsAttackLocation true(FaceLocation)
  142. }
  143.  
  144. ReacquireEnemyUnit
  145. {
  146.     EnemyUnitReachable true(CheckRange) false(ShouldIReturnToInitialContactLocation)
  147. }
  148.  
  149. RetaliateAgainstAttacker
  150. {
  151.     GoalIsUnit true(CheckRange) false(PrepareToMove)
  152. }
  153.  
  154. RunFromAttacker
  155. {
  156.     AlwaysTrue true(PrepareToMove)
  157. }
  158.  
  159. UnderAttack
  160. {
  161.     CanFlee true(RunFromAttacker)
  162.     allof(CanITargetEnemies,UnitIdleOrAttackingDefenselessBuilding,IsAttackerInRetaliationRange,CanDamageAttacker,AttackerIsReachable) true(RetaliateAgainstAttacker) false(ReacquireGoal)
  163. }
  164.